package buffered;

import java.io.*;
import java.util.TreeSet;
import java.util.function.Consumer;

public class BufferedReaderTest2 {
    public static void main(String[] args) throws IOException {
        //创建TreeSet集合，用于排序
        TreeSet<String> ts=new TreeSet<>();
        BufferedReader br=new BufferedReader(new FileReader("G:\\Javatest2\\buffered\\chushibiao.txt"));
        BufferedWriter bw=new BufferedWriter(new FileWriter("G:\\Javatest2\\buffered\\chushibiao2.txt"));
        String line;

        while((line=br.readLine())!=null){
//            将读取到的每行数据存入到集合ts
            ts.add(line);
        };
        br.close();
        for (String t : ts) {
//            写出数据
            bw.write(t);
//            增加换行符
            bw.newLine();
        }
        bw.close();
    }
}
